﻿package com.wandian.view.components.ui
{
	import com.wandian.data.GameData;
	import com.wandian.util.CLZLoadPerson;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.geom.Rectangle;

	/**
	 * 显示人物坐位图像
	 * @author long
	 * @QQ 108232706
	 * @version 1.0
	 */
	public class Person extends Sprite
	{
		public var seatId:int;

		public function Person():void
		{
			return;
		}

		public function showPersonById(personId:String, _seatId:int):void
		{
			while (this.numChildren)
			{

				this.removeChildAt(0);
			}
//			var personBitmap:*=CLZLoadPerson.personById("person_max_"+personId, "InitPerson");
			var personBitmap:* = CLZLoadPerson.personById(personId, "InitPerson");
			this.showPerson(_seatId, personBitmap);
			return;
		}

		public function updatePersonById(personId:String, personSeat:int):void
		{
			while (this.numChildren)
			{

				this.removeChildAt(0);
			}
//			var personBitmap:*=CLZLoadPerson.personById("person_max_"+personId, "InitPerson");
			var personBitmap:* = CLZLoadPerson.personById(personId, "InitPerson");
			this.showPerson(personSeat, personBitmap);
			return;
		}

		/**
		 * 根据座位，将人物图像显示
		 * @param personSeat
		 * @param _bitmapData
		 */
		private function showPerson(personSeat:int, _bitmapData:BitmapData):void
		{
			var _width:int=0;
			var _height:int=0;
			var _x:int=0;
			var _y:int=0;
			switch (personSeat)
			{
				case 1:
				{
					_width=143;
					_height=143;
					_x=571;
					_y=30;
					break;
				}
				case 2:
				{
					_width=135;
					_height=175;
					_x=738;
					_y=82;
					break;
				}
				case 3:
				{
					_width=128;
					_height=157;
					_x=750;
					_y=304;
					break;
				}
				case 4:
				{
					_width=136;
					_height=157;
					_x=569;
					_y=368;
					break;
				}
				case 5:
				{
					_width=129;
					_height=164;
					_x=420;
					_y=369;
					break;
				}
				case 6:
				{
					_width=130;
					_height=167;
					_x=249;
					_y=358;
					break;
				}
				case 7:
				{
					_width=150;
					_height=172;
					_x=82;
					_y=272;
					break;
				}
				case 8:
				{
					_width=162;
					_height=156;
					_x=78;
					_y=99;
					break;
				}
				case 9:
				{
					_width=142;
					_height=146;
					_x=256;
					_y=30;
					break;
				}
				default:
				{
					break;
				}
			}
			var bitmapData:*=new BitmapData(_width, _height, true, 0);
			bitmapData.copyPixels(_bitmapData, new Rectangle(_x, _y, _width, _height), new Point(0, 0));
			var bitmap:*=new Bitmap(bitmapData);
			this.addChild(bitmap);
			bitmap.x=_x;
			bitmap.y=_y;
			return;
		}

	}
}
